import {
  registerMicroApps,
  start,
  addGlobalUncaughtErrorHandler,
} from "qiankun";
// 微应用信息
const apps: any[] = [
  {
    name: "vue-history",
    entry: "//localhost:10002",
    container: "#frame",
    activeRule: "/vue-history",
  },
  {
    name: "vue-his", // app name registered
    entry: "//localhost:10001",
    container: "#frame1",
    activeRule: "/vue-his",
  },
];
/**
 * 注册微应用
 * 第一个参数 - 微应用的注册信息
 * 第二个参数 - 全局生命周期钩子
 */
registerMicroApps(apps, {
  beforeLoad: (app: any) => {
    console.log("before load", app.name);
    return Promise.resolve();
  },
  beforeMount: (app: any) => {
    console.log("before mount", app.name);
    return Promise.resolve();
  },
  afterMount: (app: any) => {
    console.log("after mount", app.name);

    return Promise.resolve();
  },
  beforeUnmount: (app: any) => {
    console.log("before unmount", app.name);
    return Promise.resolve();
  },
  afterUnmount: (app: any) => {
    console.log("after unmount", app.name);
    return Promise.resolve();
  },
});
/**
 * 添加全局的未捕获异常处理器
 */
addGlobalUncaughtErrorHandler((event: Event | string) => {
  console.error(event);
});
// 导出 qiankun 的启动函数
export default start;
// start();
